<template>
  <div id="RebuildList">
    <van-tabs v-model="active" color="#007DFB" line-width="60px" line-height="4px" title-active-color="#007DFB"
      @click="handleclickto" swipeable>

      <van-tab v-if="typeName !== '我要危改申请'" title="我的待办">
        <div style="padding: 4px">
          <van-search v-model="cqr" style="border-radius: 10px; height: 44px" background="#f7f8fa"
            placeholder="请输入产权人姓名检索" @search="onSearch" />
        </div>
        <ul class="listWrap" v-if="listData.length > 0">
    <li v-for="(item, index) in listData" :key="index">
            <p class="p1">
              <span style="float: left">{{ item.propertyPerson }}</span>
              <span style="float: right;">
                <van-button plain type="info" size="mini" @click="ApprovalProgress(item)">审批进度</van-button>
                <van-button plain type="info" size="mini" @click="ProcessDetails(item)">办理详情</van-button>
              </span>
            </p>
            <div @click="listClick(item)">
              <p class="p3">
                <span style="float: left">自建房排查编号：{{ item.checkNumber }}</span>
              </p>
              <p class="p3">
                <span style="float: left">当前阶段：{{ item.processNodeName }}</span>
                <span style="float: right">用户类型:{{ item.userTypeName }}</span>
              </p>
              <p class="p3">
                <span style="float: left">地址：{{ item.belongCity }} {{ item.belongCounty }} {{ item.belongTown }}
                  {{ item.villageName }}</span>
              </p>
            </div>
            <!-- <p class="p1">
                <span style="float: left">{{ item.NODE_NAME }}</span>
                <span v-if="item.propertyPerson" style="float: right">
                 产权人: {{ item.propertyPerson }}
                </span>
                <span v-else-if="item.F_HOUSEAPPLICANT" style="float: right">
                  {{ item.F_HOUSEAPPLICANT }}
                </span>
                <span v-else-if="item.F_CQR" style="float: right">
                  {{ item.F_CQR }}
                </span>
              </p> -->
            <!-- <p class="p3">
                <span style="float: left">进度：{{ item.PROC_NAME }}</span>
                <span style="float: right" v-if="item.SQSJ">申请时间：{{ item.SQSJ }}</span>
                <span style="float: right" v-if="item.F_TROUBLESHOOTINGTIME">排查时间：{{
                  item.F_TROUBLESHOOTINGTIME.split(" ")[0]
                }}</span>
              </p> -->
            <!-- <p class="p3">
                <span v-if="item.FWDZ" style="float: left">地址：{{
                  item.FWDZ
                }}</span>
                <span v-else-if="item.F_PERMANENTADDR" style="float: left">地址：{{ item.F_PERMANENTADDR }}</span>
                <span v-else-if="item.F_ADDRESS" style="float: left">地址：{{ item.F_ADDRESS }}</span>
                <span style="float: right" v-else>暂无数据</span>
              </p> -->
          </li>
        </ul>
        <ul v-else>
          <div style="height: 60vh; text-align: center; padding-top: 20vh">
            <div style="margin-bottom: 10px">
              <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png" />
            </div>
            <div>暂无数据</div>
          </div>
        </ul>
      </van-tab>
      <van-tab v-else title="我的待办2">
        <ul class="listWrap" v-if="listData.length > 0">
          <li v-for="(item, index) in listData" :key="index" @click="listClick1(item)">
            <p class="p1">
              <span style="float: left">{{ item.propertyPerson }}</span>

              <span style="float: right">
                {{ item.checkNumber }}
              </span>
            </p>
            <p class="p3">
              <span style="float: left">所属乡镇:{{ item.belongCity }} {{ item.belongCountry }} {{ item.belongTown }}
                {{ item.belongVillage }}</span>

            </p>
            <p class="p3">
              <span style="float: left">地址:{{ item.detailAddress }}</span>

            </p>
          </li>
        </ul>
        <ul v-else>
          <div style="height: 60vh; text-align: center; padding-top: 20vh">
            <div style="margin-bottom: 10px">
              <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png" />
            </div>
            <div>暂无数据</div>
          </div>
        </ul>
      </van-tab>
      <van-tab title="申请记录">
        <wgsearch ref="wgsearch"></wgsearch>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { FileServerProxy, personToDoListV2 } from "@/utils/api";
import wgsearch from "./wgsearch";
import { Dialog } from "vant";
export default {
  name: "RebuildList",
  data() {
    return {
      cqr: "",
      listData: [
      ],
      active: '0'
    };
  },
  props: ["typeName"],
  components: {
    wgsearch
  },
  methods: {
    ApprovalProgress(item){
      this.$store.state.wgxxInfo = JSON.stringify(item)
      this.$router.push({
        path: '/ApprovalProgress',
        query:{
          data: JSON.stringify(item)
        }
      })
    },
    ProcessDetails(item){
      this.$store.state.wgxxInfo = JSON.stringify(item)
      this.$router.push({
        path: '/ProcessDetails',
        query:{
          data: JSON.stringify(item)
        }
      })
    },   
 onSearch() {
      this.getListData()
    },
    handleclickto() {

    },
    getListData: async function () {
      debugger
      if (this.typeName === '危改申请') {
        // window.localStorage.getItem('DanDianid')
        let params = {
          "householderIdCard": window.localStorage.getItem('DanDianid'),
          "pageNo": 1,
          "pageSize": 1000,
          "userName": this.cqr,
          "useType": 2
        };
        const res = await personToDoListV2(params);
        console.log(res)
        if (res.data.data && res.data.data.pageList.length > 0) {
          this.listData = res.data.data.pageList
        } else {
          this.listData = [];
        }

      } else {
        // let params = {
        //   accessCode: "688bd3883572440a859dfd8ba9194e7b",
        //   cityCode: window.localStorage.getItem("citycode")
        //     ? window.localStorage.getItem("citycode")
        //     : "441300000000",
        //   params: {
        //     dataguid: "bcc27d4d-8597-4156-b914-22cf594780d2",
        //     searchObject: JSON.stringify([]),
        //     token: window.localStorage.getItem("token"),
        //   },
        // };
        // const res = await FileServerProxy(params);
        // this.listData = JSON.parse(res.data.data).Data;
        // let params1 = {
        //   accessCode: "688bd3883572440a859dfd8ba9194e7b",
        //   cityCode: window.localStorage.getItem("citycode")
        //     ? window.localStorage.getItem("citycode")
        //     : "441300000000",
        //   params: {
        //     dataguid: "20966a43-764f-43ac-9c7c-ca0d440e5605",
        //     searchObject: JSON.stringify([]),
        //     token: window.localStorage.getItem("token"),
        //   },
        // };
        // const res1 = await FileServerProxy(params1);
        // this.listData = this.listData.concat(JSON.parse(res1.data.data).Data);
        // let params2 = {
        //   accessCode: "688bd3883572440a859dfd8ba9194e7b",
        //   cityCode: window.localStorage.getItem("citycode")
        //     ? window.localStorage.getItem("citycode")
        //     : "441300000000",
        //   params: {
        //     dataguid: "cf5a8d5f-e867-4ee3-b465-a522f6c87d4e",
        //     searchObject: JSON.stringify([]),
        //     token: window.localStorage.getItem("token"),
        //   },
        // };
        // const res2 = await FileServerProxy(params2);
        // console.log(JSON.parse(res2.data.data).Data);
        // this.listData = this.listData.concat(JSON.parse(res2.data.data).Data);
        // console.log(this.listData)
      }

    },
    handleGoto() {
      this.$router.push({
        path: "/myshenQing1",
        query: {
          data: "1",
        },
      });
    },
    listClick(item) {
      debugger
      if ((item.processNode == "20" || item.processNode == 0) && item.isHasHouse == 1) {
        //选择鉴定公司
        this.$router.push({
          path: '/ApplyappraisalCompany',
          query: {
            data: JSON.stringify(item),
            type: true
          }
        })
      } else if (item.usccName) {
        Dialog.confirm({
          message: `您当前选择的鉴定公司是${item.usccName},是否重新选择提交！`,
        }).then(() => {
          this.$router.push({
            path: '/ApplyappraisalCompany',
            query: {
              data: JSON.stringify(item),
              type: true
            }
          })
        })
      }
      else {
        this.$toast.fail("当前环节不需要您办理!")
        //http://192.168.4.50:9002//api/farmerHouse/dangerHouseProcessV2/processList
      }
      //alert(item);
      // console.log(item)
      // // 镇街督办
      // if (item.WF_GUID === '{AFA7FC7F-BDBD-46EA-ABD2-EEF0766096D2}') {
      //   switch (item.NODE_GUID) {
      //     // 鉴定公司
      //     case '{3F794E03-9253-439B-8332-79BCBDE26294}':
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break
      //     // 复核鉴定
      //     case '{B4FCC404-5D84-4F9A-B5A2-243ECE2FB244}':
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break
      //   }
      // } else {
      //   switch (item.NODE_GUID) {
      //     // （农户）危改申请
      //     case "{5E869057-F0CA-4E87-80D4-9B7FECEAFE9E}":
      //       break;
      //     // 鉴定公司鉴定
      //     case "{C856358A-5B9A-42F0-814D-5BF3F63F5929}":
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     case "{4A140424-C781-402F-A821-502828EB75DA}":
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     //  农户申请
      //     case "{7A629180-CF1F-4600-AB4C-33E33ED1E743}":
      //       this.$router.push({
      //         path: "/FarmersRenovation1",
      //         query: {
      //           data: JSON.stringify(item),
      //         },
      //       });
      //       break;
      //     // 农户危房整治
      //     case "{0C256BFE-BC5F-4D63-8AEC-4630EC19F78B}":
      //       if (item.JWFS == "265") {
      //         this.$router.push({
      //           path: "/FarmersRenovation",
      //           query: { data: JSON.stringify(item) },
      //         });
      //       } else {
      //         this.$router.push({
      //           path: "/FarmersRenovation",
      //           query: { data: JSON.stringify(item) },
      //         });
      //       }
      //       break;
      //     //  申请复核鉴定
      //     case "{27EE0E9F-607B-4D25-8934-3693F950C095}":
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     case "{7A93D2DC-D4B9-4E6A-8DC6-4C2FDFBB9D45}":
      //       this.$router.push({
      //         path: "/DangerousAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     //    申请建房补助
      //     case "{B3882940-DD70-48B9-BCDC-544280832103}":
      //       this.$router.push({
      //         path: "/SubsidyApplication",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     //  房屋安全鉴定
      //     case "{53BC28FE-1869-4C12-9683-92B5B059D1BB}":
      //       this.$router.push({
      //         path: "/SafetyAppraisal",
      //         query: { data: JSON.stringify(item) },
      //       });
      //       break;
      //     //  农户危房改造
      //     case "{6048BDEF-057A-4080-A536-D9EEE89626D7}":
      //       this.$router.push({
      //         path: "/FarmersRenovation",
      //         query: {
      //           data: JSON.stringify(item),
      //           type: "NHWFGZ",
      //         },
      //       });
      //       break;
      //   }
      // }

    },
    listClick1(item) {
      debugger
      this.$router.push({
        path: "/appraisalCompanyDetails",
        query: { data: item.objectNo },
      });
    }
  },
  mounted() {
    this.getListData();
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: "我的危改",
      })
        .then((re2s) => {
        })
        .catch((err) => {
        });
    }
  },
};
</script>

<style scoped lang="scss">
#RebuildList {
  height: 100%;
  overflow: auto;
}
</style>
